package com.sta.oldman.coder;

import lombok.Data;

import java.util.Arrays;

/**
 * @author: LunBoWang
 * @description: 消息体
 * @date: 2025/5/25 下午7:36
 * @version: 1.0
 */
@Data
public class TcpMsg {
    private short header;
    private byte control;
    private byte command;
    // 使用short类型更合适，转换为long存储
    private short length;
    private byte[] data;
    private byte sum;
    private short tail;

    public TcpMsg(byte control, byte command, short length, byte[] data, byte sum) {
        this.header =  0x5359;
        this.control = control;
        this.command = command;
        this.length = length;
        this.data = data;
        this.tail = 0x5443;
        this.sum = sum;
    }

    @Override
    public String toString() {
        return "TcpMsg{" +
                "header=" + header +
                ", control=" + control +
                ", command=" + command +
                ", length=" + length +
                ", data=" + Arrays.toString(data) +
                ", sum=" + sum +
                ", tail=" + tail +
                '}';
    }
}
